/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kebut.ui;

import java.awt.Rectangle;
import java.util.ArrayList;

public class SteButton{
    public String command;
    public int type;
    public Rectangle area;
    public int state;
    public boolean visible;
    
    public SteButton(String command, int type, int x, int y, int width, int height) {
        this.type = type;
        this.command = command;
        area = new Rectangle(x,y,width,height);
        state = UI.S_NORMAL;
        visible = true;
    }
    
    public SteButton(String command, int type, int x, int y, int width, int height, boolean visible) {
        this.type = type;
        this.command = command;
        area = new Rectangle(x,y,width,height);
        state = UI.S_NORMAL;
        this.visible = visible;
    }
    
    public boolean isHover(int x, int y) {
        return area.contains(x,y);
    }
    
        
    public void Hover() {
        //state = UI.S_HOVER;
        //System.out.println("HOVERING " + command);
    }
    
    public void Press() {
        //state = UI.S_PRESS;
        if (visible)
            System.out.println("PRESS " + command);
    }
    
    public void Normal() {
        //state = UI.S_NORMAL;
        if (visible)
            System.out.println("CLICK " + command);
    }
    
    public static int find(int x, int y, ArrayList<SteButton> b) {
        int result = -1;
        for (SteButton but : b) {
            if ((but.isHover(x, y)) && (but.visible))  return b.indexOf(but);
        }
        return result;
    }

}
